package com.organization

import grails.test.*
import grails.converters.JSON

class TreeControllerUnitTests extends ControllerUnitTestCase {

    TreeControllerUnitTests(){
        super(TreeController)
    }

    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testIndex() {
        def mockControl = mockFor(TreeService)
        mockControl.demand.getBranch(1..1) {params->
            return [success:"true"]
        }
        controller.treeService = mockControl.createMock()
        this.controller.params.node = "node"
        this.controller.params.nodeBdId = "nodeDbId"
        this.controller.index()
        def controllerResponse = mockResponse.contentAsString
        def jsonResult = JSON.parse(controllerResponse)
        assertNotNull "Missing success field", jsonResult.success
    }
}
